﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AAA.Chart.Data;
using System.Drawing;

namespace AAA.Chart.Component
{
    public abstract class DefaultDrawMethod : IDrawMethod
    {
        #region IDrawChart Members

        private IChartMeta _cmChartMeta;
        private List<float> _lstDataSource1;
        private List<float> _lstDataSource2;
        private List<float> _lstDataSource3;
        private List<float> _lstDataSource4;
        private string _strName;
        private Color _cForeColor;
        private Color _cBackColor;
        private int _iWidth;
        private int _iStartIndex;
        private int _iEndIndex;
        private float _fLastPrice;
        private float _fLastVolume;

        public abstract void Draw(System.Drawing.Graphics g);

        protected bool IsValidate(int[] iPixels)
        {
            foreach (int iValue in iPixels)
                if (iValue == int.MaxValue)
                    return false;
            return true;
        }

        protected int PointOffset()
        {
            return (int)Math.Floor(Width / 2.0);
        }

        protected List<float> XDataSource
        {
            get { return _lstDataSource1; }
        }

        protected List<float> YDataSource
        {
            get { return _lstDataSource2; }
        }

        protected List<float> TimeDataSource
        {
            get { return _lstDataSource3; }
        }

        protected List<float> Open
        {
            get { return _lstDataSource1; }
        }

        protected List<float> High
        {
            get { return _lstDataSource2; }
        }
        
        protected List<float> Low
        {
            get { return _lstDataSource3; }
        }

        protected List<float> Close
        {
            get { return _lstDataSource4; }
        }

        protected string Name
        {
            get { return _strName; }
        }

        protected Color ForeColor
        {
            get { return _cForeColor; }
        }

        protected Color BackColor
        {
            get { return _cBackColor; }
        }

        protected int Width
        {
            get { return _iWidth; }
        }

        public IChartMeta ChartMeta
        {
            get { return _cmChartMeta; }
            set {_cmChartMeta = value;}
        }

        public int StartIndex
        {
            get { return _iStartIndex; }
            set { _iStartIndex = value; }
        }

        public int EndIndex
        {
            get { return _iEndIndex; }
            set { _iEndIndex = value; }
        }

        public float LastPrice
        {
            get { return _fLastPrice; }
            set { _fLastPrice = value; }
        }

        public float LastVolume
        {
            get { return _fLastVolume; }
            set { _fLastVolume = value; }
        }

        public void Plot(List<float> lstDataSource1, 
                         List<float> lstDataSource2, 
                         List<float> lstDataSource3, 
                         List<float> lstDataSource4, 
                         string strName, 
                         Color cForeColor, 
                         Color cBackColor, 
                         int iWidth)
        {
            _lstDataSource1 = lstDataSource1;
            _lstDataSource2 = lstDataSource2;
            _lstDataSource3 = lstDataSource3;
            _lstDataSource4 = lstDataSource4;
            _strName = strName;
            _cForeColor = cForeColor;
            _cBackColor = cBackColor;
            _iWidth = iWidth;
        }

        #endregion
    }
}
